import {REFRESH_PAGE_TYPE} from "@/views/business/constantData";

const changePageMixins = {
  data() {
    const PAGE_SHOW_TYPE = {
      LIST: "list",
      INFO: 'info'
    }
    return {
      PAGE_SHOW_TYPE,
      currentPageShowType: PAGE_SHOW_TYPE.LIST,
      currentItem: {},
    }
  },
  methods: {
    goInfoPage(currentItem) {
      this.currentItem = _.cloneDeep(currentItem)
      this.changePage(this.PAGE_SHOW_TYPE.INFO)
    },
    goListPage(refreshPageType) {
      if (refreshPageType == REFRESH_PAGE_TYPE.REFRESH && this.$refs.listPage &&  this.$refs.listPage.getListData) {
        this.$refs.listPage.getListData();
      }
      this.changePage(this.PAGE_SHOW_TYPE.LIST)
    },
    changePage(showType) {
      this.currentPageShowType = showType
    }
  }
};

export {changePageMixins}
